﻿namespace System
{
    public static class SystemExtensions
    {
        /// <summary>
        /// Replaces the format item in a specified System.String wht the text equivalent of the value of a corresponding System.Object instance in a specified array.
        /// </summary>
        /// <param name="source">A composite format string.</param>
        /// <param name="args">A System.Object array containing zero or more objects to format.</param>
        /// <returns>A copy of source in whihce the format items have been replaced by the System.String equivalent of the corresponding instances of System.Object in args.</returns>
        public static string FormatWith(this string source, params object[] args)
        {
            return String.Format(source, args);
        }

        /// <summary>
        /// Checks a System.Type to see if it implements a given interface.
        /// </summary>
        /// <param name="source">The System.Type to check.</param>
        /// <param name="iface">The System.Type interface to check for.</param>
        /// <returns>True if the source implements the interface type, false otherwise.</returns>
        public static bool IsImplementationOf(this Type source, Type interfaceType)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            return source.GetInterface(interfaceType.FullName) != null;
        }
    }
}
